package blip.jcaf.cm;

import java.io.Serializable;
import java.util.Observable;
import java.util.Observer;

@SuppressWarnings("serial")
public class BLIP_device_trackerActivity implements Observer, Serializable {

	String newLocation;
	private String btLocation;

	public BLIP_device_trackerActivity(String btId) {
		newLocation = "";
		connectToREST("http://pit.itu.dk:7331/location-of/"+btId);
	}

	private void connectToREST(String url) {
		AsyncConnection connection = new AsyncConnection(url, this);
		new Thread(connection).start();
	}

	private void updateDisplay() {
		btLocation = newLocation;
	}

	public void update(Observable observable, Object data) {
		String castData = (String) data;
		newLocation = castData;
		updateDisplay();
	}
	
	public String getBlipLocation() {
		return btLocation;
	}
	
	public void deviceGone() {
		
	}
	
	public void setFakeBlipLocation(String fakeness) {
		BLIPTestClient fakeInput = new BLIPTestClient(fakeness);
		btLocation = fakeInput.getFakeLocation();
	}
	

}